<template>
	<view class="mainpadding2">
		<!-- 占位图 -->
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="margin_top xiahuaxian" v-for="item in list.data" :key="item.id" @click="selectrole(item.id)">
			<view class="flexbetween">
				<view class="">
					<view class="flexleft">
						<view class="xiaolv sanshier nofonweight" v-show="item.status==1">【默认】</view>
						<view class="xiaohei sanshier nofonweight margin_right2">{{item.name}}</view>
						<view class="xiaohui ershiba nofonweight">{{item.mobile}}</view>
					</view>
					<view class="xiaohei ershiba nofonweight margin_top2">{{item.cityinfo}}{{item.address_detail}}</view>
				</view>
				<view class=""  @click.stop="bjdz(item.id)">
					<u-icon name="edit-pen" size="24"></u-icon>
				</view>
			</view>
		</view>
		<view class="mainpadding gudingdb" @click="tzxzdz">
			<view class="bigbtn">新增地址</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				type: "",
				page: 1,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			this.type = options.type
		},
		onShow() {
			this.init();
		},
		methods: {
			selectrole(id){
				if(this.type==1){
					uni.$emit("checkaddress",id)
					uni.navigateBack(1)
				}
			},
			init() {
				let _this = this;
				httpRequest.request("/api/user/addressList", 'GET', {
				}, false, false, true).then(res => {
					this.list.data = res.data
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			// 跳转新增地址
			tzxzdz() {
				uni.navigateTo({
					url: '/pages_mypage/xinzengdizhi'
				})
			},
			bjdz(id) {
				uni.navigateTo({
					url: '/pages_mypage/xinzengdizhi?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zwdizhi {
		height: 508rpx;
		margin: 30rpx auto 0;
		width: 444rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>